package component.dispatcher;

import analyser.node.v2.*;
import model.MibModule;
import util.common.MibKeys;

import java.util.Collection;
import java.util.List;
import java.util.Map;

public class NodeAnalyseDispatcherV2 extends NodeAnalyseDispatcher {
    private static final String SNMPv2_SMI = "SNMPv2-SMI";
    private static final String SNMPv2_TC = "SNMPv2-TC";
    private static final String SNMPv2_CONF = "SNMPv2-CONF";

    public NodeAnalyseDispatcherV2(MibModule module) {
        super(module);
    }

    public NodeAnalyseDispatcherV2(MibModule module, NodeAnalyseDispatcher next) {
        super(module, next);
    }

    @Override
    protected void despatch() {
        Map<String, List<String>> importsMap = this.module.ImportsModuleNodesMap;
        Collection<String> collection;
        if (importsMap != null){
            if (importsMap.containsKey(SNMPv2_SMI)){
                collection = importsMap.get(SNMPv2_SMI);
                for(String name : collection){
                    switch (name){
                        case MibKeys.MODULE_IDENTITY:
                            typeAnalyserMap.put(name, MibModuleIdentityV2Analyser.class);
                            break;
                        case MibKeys.OBJECT_TYPE:
                            typeAnalyserMap.put(name, MibObjectTypeV2Analyser.class);
                            break;
                        case MibKeys.NOTIFICATION_TYPE:
                            typeAnalyserMap.put(name, MibNotificationTypeV2Analyser.class);
                            break;
                    }
                }
            }
            if (importsMap.containsKey(SNMPv2_CONF)){
                collection = importsMap.get(SNMPv2_CONF);
                for(String name : collection){
                    switch (name){
                        case MibKeys.OBJECT_GROUP:
                            typeAnalyserMap.put(name, MibObjectGroupV2Analyser.class);
                            break;
                        case MibKeys.NOTIFICATION_GROUP:
                            typeAnalyserMap.put(name, MibNotificationGroupV2Analyser.class);
                            break;
                        case MibKeys.MODULE_COMPLIANCE:
                            typeAnalyserMap.put(name, MibModuleComplianceV2Analyser.class);
                            break;
                    }
                }
            }
        }
    }
}
